﻿<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!doctype html>
<html>

	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<title>商品列表</title>
		<link rel="stylesheet" href="${pageContext.request.contextPath}/css/bootstrap.min.css" type="text/css" />
		<script src="${pageContext.request.contextPath}/js/jquery-1.11.3.min.js" type="text/javascript"></script>
		<script src="${pageContext.request.contextPath}/js/bootstrap.min.js" type="text/javascript"></script>
		<!-- 引入自定义css文件 style.css -->
		<link rel="stylesheet" href="${pageContext.request.contextPath}/css/style.css" type="text/css"/>

		<style>
			body {
				margin-top: 20px;
				margin: 0 auto;
				width: 100%;
			}
			.carousel-inner .item img {
				width: 100%;
				height: 300px;
			}
		</style>
	</head>

	<body>
		
 <%@ include file="header.jsp"%>


 	<c:if test="${not empty pageInfo.list}">
		<%--		页面数据--%>
		<div class="row" style="width:1210px;margin:0 auto;">

			<c:forEach items="${pageInfo.list}" var="product">

				<div class="col-md-2">
					<a href="${pageContext.request.contextPath}/productServlet?method=findProductByPid&pid=${product.pid}">
						<img src="${pageContext.request.contextPath}/${product.pimage}" width="170" height="170" style="display: inline-block;">
					</a>
					<p><a href="${pageContext.request.contextPath}/productServlet?method=findProductByPid&pid=${product.pid}" style='color:green'>${product.pname}</a></p>
					<p><font color="#FF0000">商城价：&yen;${product.shopPrice}</font></p>
				</div>

			</c:forEach>

		</div>

		<!--分页 页码  -->
		<div style="width:380px;margin:0 auto;margin-top:50px;">
			<ul class="pagination" style="text-align:center; margin-top:10px;">
				<c:if test="${pageInfo.pageNum == 1}">
<%--					 当前页 是第1页, 让上一页按钮 不起作用 --%>
					<li class="disabled"><a href="#" aria-label="Previous"><span aria-hidden="true">&laquo;</span></a></li>
				</c:if>
				<c:if test="${pageInfo.pageNum > 1}">
<%--					当前页 不是第1页而是后边的页 此时让 上一页按钮起作用--%>
					<li ><a href="${pageContext.request.contextPath}/productServlet?method=findProductByCid&cid=${cid}&pageNum=${pageInfo.prePage}" aria-label="Previous"><span aria-hidden="true">&laquo;</span></a></li>
				</c:if>
<%--				显示所有的页码 --%>
				<c:forEach begin="1" end="${pageInfo.pages}" step="1" var="i">
<%--					给当前页加蓝色背景--%>
					<c:if test="${pageInfo.pageNum == i}">
						<li class="active"><a href="${pageContext.request.contextPath}/productServlet?method=findProductByCid&cid=${cid}&pageNum=${i}">${i}</a></li>
					</c:if>
<%--					不是当前页的 无需添加 蓝色背景--%>
					<c:if test="${pageInfo.pageNum != i}">
						<li><a href="${pageContext.request.contextPath}/productServlet?method=findProductByCid&cid=${cid}&pageNum=${i}">${i}</a></li>
					</c:if>

				</c:forEach>

<%--				下一页逻辑 --%>
<%--				判断当前页 是否为最后一页, 如果是 就不让下一页起作用, 否则就让下一页起作用 --%>
				<c:if test="${pageInfo.pageNum < pageInfo.pages}">
					<li>
						<a href="${pageContext.request.contextPath}/productServlet?method=findProductByCid&cid=${cid}&pageNum=${pageInfo.nextPage}" aria-label="Next">
							<span aria-hidden="true">&raquo;</span>
						</a>
					</li>
				</c:if>
				<c:if test="${pageInfo.pageNum == pageInfo.pages}">
					<li class="disabled">
						<a href="#" aria-label="Next">
							<span aria-hidden="true">&raquo;</span>
						</a>
					</li>
				</c:if>



			</ul>
		</div>
	</c:if>
 	<c:if test="${empty pageInfo.list}">
		<h1>该分类下 没有商品 </h1>
	</c:if>

		<!-- 分页结束=======================        -->




		<div style="margin-top:50px;">
			<img src="${pageContext.request.contextPath}/img/footer.jpg" width="100%" height="78" alt="我们的优势" title="我们的优势" />
		</div>

		<div style="text-align: center;margin-top: 5px;">
			<ul class="list-inline">
				<li><a href="${pageContext.request.contextPath}/jsp/info.jsp">关于我们</a></li>
				<li><a>联系我们</a></li>
				<li><a>招贤纳士</a></li>
				<li><a>法律声明</a></li>
				<li><a>友情链接</a></li>
				<li><a target="_blank">支付方式</a></li>
				<li><a target="_blank">配送方式</a></li>
				<li><a>服务声明</a></li>
				<li><a>广告声明</a></li>
			</ul>
		</div>
		<div style="text-align: center;margin-top: 5px;margin-bottom:20px;">
			Copyright &copy; 2005-2016 传智商城 版权所有
		</div>

	</body>

</html>